<!doctype html>
<html onkeypress="keypress(event)">
<script>

blink_on = null;
inputrow=null;
input_buffer = null;
function init()
{
	inputrow = document.getElementById("inputrow");
	terminal_div=document.getElementById("terminal");
	blink_on = true;
	input_buffer="";
	blink();
	inputrow.innerHTML = "Hi!"
}
function blink()
{
	blink_on = ! blink_on;
	window.setTimeout("blink()",500);
	redraw_buffer();
}
function redraw_buffer()
{
	if(blink_on) 
		inputrow.innerHTML = input_buffer+"<b>_</b>"
	else 
		inputrow.innerHTML = input_buffer;
}

function keypress(evt)
{
	if (evt.type == "keypress"){ //some browsers support evt.charCode, some only evt.keyCode;
		if (evt.charCode) {
			var charCode = evt.charCode;}
		else {
			var charCode = evt.keyCode;}}

	input_buffer+=String.fromCharCode(charCode);
	
	if(charCode==13) // return is pressed
	{
		terminal_div.innerHTML+="<br />"+input_buffer;
		input_buffer="";
	}
	redraw_buffer();
}
window.setTimeout("init()",10);
</script>

<body>
<div id="terminal">~~</div>
<div id="inputrow">&gt;</div>
</body>
</html>
